using Microsoft.Xna.Framework;

namespace ADiKt {
    /// <summary> 
    /// The pause menu comes up over the top of the game, giving 
    /// the player options to resume or quit(with conformation).
    /// </summary>
    class PauseMenuScreen : MenuScreen {
        public PauseMenuScreen(): base("Paused") {
            // Create our menu entries.
            MenuEntry resumeGameMenuEntry = new MenuEntry("Resume Game");
            MenuEntry quitGameMenuEntry = new MenuEntry("Quit Game");

            // Hook up menu event handlers.
            resumeGameMenuEntry.Selected += OnCancel;
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(quitGameMenuEntry);
        }

        /// <summary> Event handler for when the Quit Game menu entry is selected. </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e) {
            const string message = "Quit to main menu?";
            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true);
            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }

        /// <summary> Event handler for when the user confirms quit</summary>
        void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e) {
            LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
        }

    }
}
